#include "comm.h"
int main()
{
  if(mkfifo(FILE_NAME,0644)<0)
  {
    perror("mkfilo error\n");
    return 1;
  }
  int fd=open(FILE_NAME,O_RDONLY);
  
   if(fd<0)
   {
     perror("open file\n");
     return 2;
   }
  
  int out=open("file.cp",O_CREAT|O_WRONLY,0644);
  char msg[128];
  while(1)
  {
    ssize_t s=read(fd,msg,sizeof(msg));
    if(s>0)
    {
      write(out,msg,s);
    }
    else if(s==0)
    {
      printf("client quit\n");
      break;
    }
    else 
    {
      break;
    }
  }
  return 0;
}
